<template>
  <el-upload class="upload-demo"
             action="/api/UploadMedia"
             :on-success="handleChange"
             accept=".mp4"
             :file-list="fileList"
             :before-upload="beforeAvatarUpload">
    <el-button size="small"
               type="primary">点击上传视频</el-button>
  </el-upload>
</template>

<script>
export default {
    data() {
        return {
            fileList: []
        };
    },
    methods: {
        changeVideo(res) {
            this.$emit('videoUrlChange', res);
        },
        handleChange(resp) {
            this.changeVideo('http://' + resp.data);
        },
         beforeAvatarUpload(file) {
        
            const isLt2M = file.size / 1024 / 1024 < 50;
           
            if (!isLt2M) {
                this.$message.error('上传视频大小不能超过 50MB!');
            }
            return isLt2M;
        }
    }
};
</script>
<style>
.uploadVideo .el-upload--text {
    width: 180px;
    height: 60px;
    border: 0px;
    margin-left: -25px;
}
</style>